//
//  LLUserInfo.m
//  LoveLove
//
//  Created by leiyifan on 2019/5/21.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLUserInfo.h"

@implementation LLUserInfo
singleton_m(User)

-(instancetype)initWithDic:(NSDictionary *)dic{
    if (self = [super init]) {
        self.user_avatar = [NSString stringWithFormat:@"%@",dic[@"user_avatar"]];
        self.user_follow = [NSString stringWithFormat:@"%@",dic[@"user_follow"]];
        self.user_id = [NSString stringWithFormat:@"%@",dic[@"user_id"]];
        self.user_login = [NSString stringWithFormat:@"%@",dic[@"user_login"]];
        self.user_name = [NSString stringWithFormat:@"%@",dic[@"user_name"]];
        self.user_random = [NSString stringWithFormat:@"%@",dic[@"user_random"]];
        self.user_report = [NSString stringWithFormat:@"%@",dic[@"user_report"]];
        self.user_point = [NSString stringWithFormat:@"%@",dic[@"user_point"]];
         self.user_info = [NSString stringWithFormat:@"%@",dic[@"user_info"]];
        
    }
    return self;
}

+ (instancetype) getUserInfoFromLocal;
{
    NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"userinfo"];
    LLUserInfo *info;
    if (dict) {
        info = [[LLUserInfo alloc] initWithDic:dict];
    }

    return info;
}

+ (void) saveUserInfoToLocal:(NSDictionary *)dict;
{
    [[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"userinfo"];
}

+ (void) clearLocalUserInfo;
{
    [[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"userinfo"];
}

@end
